#include "threadPool.h"


using namespace easyWebServer;

ThreadPool::ThreadPool()
{

}

ThreadPool::~ThreadPool()
{

}

void ThreadPool::start()
{
    for(int i = 0; i < m_threadNum; i++)
    {
        m_threadTasks.push_back(unique_ptr<TDTask>(new TDTask()));
    }
}

void ThreadPool::stop()
{
    for(int i = 0; i < m_threadNum; i++)
    {
        m_threadTasks[i]->stop();
    }
    Singleton<condition_variable>::getInstance().notify_all();
    for(int i = 0; i < m_threadNum; i++)
    {
        m_threadTasks[i]->join();
    }
}

void ThreadPool::setThreadNum(int threadNum)
{
    m_threadNum = threadNum;
}



